package com.next

class Attachment
{
    AttachmentType type
    String fileName
    String fileUrl
    String thumbnailUrl

    String description

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    Integer displayOrder = 0

    User createBy
    User modifyBy
    User user

    String externalId

    Activity activity
    Account account
    Contact contact
    Campaign campaign
    Opportunity opportunity
    Issue issue
    Lead lead
    Asset asset
    Contract contract

    static constraints = {
        // fileName nullable: true, blank: true
        description nullable: true, blank: true, maxSize: 1024
        contact nullable: true, blank: true
        fileUrl maxSize: 512, nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true
        externalId maxSize: 32, blank: true, nullable: true
        thumbnailUrl maxSize: 512, nullable: true, blank: true
        user nullable: true, blank: true

        activity nullable: true, blank: true
        account nullable: true, blank: true
        contact nullable: true, blank: true
        campaign nullable: true, blank: true
        opportunity nullable: true, blank: true
        lead nullable: true, blank: true
        issue nullable: true, blank: true
        asset nullable: true, blank: true
        contract nullable: true, blank: true
    }

    static mapping = {
        sort 'type', 'fileName'
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
    }
}
